/**
    ATClab - scriptable Air Traffic Control simulations.
    Copyright (C) 2010 openatclab@gmail.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
**/

#ifndef __PERFORMANCE_ATMOSPHERE_HDR__
#define __PERFORMANCE_ATMOSPHERE_HDR__

#include "data.h"

namespace performance {

	//
	// performance::constants
	//

	const double MPERNM = 1852.0;        // meters / nautical mile
	const double MPERFT = 0.3048;        // meters / foot

	// Data for air ...

	const double R     = 1718.0;     // gas constant R, in ft2/sec2/degF
	const double GAMMA = 1.4;        // gamma, ratio of specific heats

	// Data for standard day @ sea level ...

	const double T0   = 518.67;         // absolute temperature, deg F
	const double P0   = 2116.2;         // pressure, lb/ft2
	const double RHO0 = 0.002378;       // density, slugs/ft3
	const double A0   = 661.7556275;    // speed of sound, Kt


	//
	// performance::AtmosParam
	//

	struct AtmosParam {

		double alt;     // altitude, in feet
		double t;       // temperature
		double p;       // pressure
		double rho;     // density
		double a;       // speed of sound
		double delta;   // p/p0

	};

    //
    // performance::Atmosphere
    //

    class Atmosphere {

    public:
		Atmosphere( const std::vector< double > & );
        ~Atmosphere();

    public:
		double cas2mach( int, double ) const;
		double  cas2tas( int, double ) const;
		double mach2tas( int, double ) const;
		
		double cas2tas_max( int, double, bool ) const ;

	private:
		void calc_param( double, AtmosParam & );

	private:
		std::vector< AtmosParam > _params;

	};


};
#endif
